<template>
    <el-form-item label="数据源" prop="writerDatasourceId">
        <el-select v-model="form.writerDatasourceId" filterable>
            <el-option
                v-for="item in  sourceList.filter(e=>e.datasourceType.indexOf('ftp')!=-1)" :key="item.datasourceId"
                :label="item.datasourceName + '_' + item.datasourceType"
                :value="item.datasourceId"/>
        </el-select>
    </el-form-item>
    <el-form-item label="文件编码" prop="writerFileEncoding">
        <el-select v-model="form.writerFileEncoding" placeholder="请选择文件编码" default-first-option filterable>
            <el-option v-for="item in writerFileEncodingList" :key="item" :label="item" :value="item"/>
        </el-select>

    </el-form-item>
    <el-form-item label="文件路径" prop="writerFilePath">
        <el-input type="textarea" v-model="form.writerFilePath" placeholder="请输入文件路径" clearable/>
    </el-form-item>
    <el-form-item label="文件名" prop="writerFileName">
        <el-input v-model="form.writerFileName" placeholder="文件名前缀，为空则与源端相同" clearable/>
    </el-form-item>
    <el-form-item label="写入前处理模式" prop="writeMode">
        <el-select v-model="form.writeMode" placeholder="请选择写入前处理模式" default-first-option filterable>
            <el-option v-for="item in writeModeList" :key="item" :label="item" :value="item"/>
        </el-select>
    </el-form-item>
    <el-form-item label="文件输出格式" prop="fileFormat">
        <el-select v-model="form.fileFormat" placeholder="请选择文件输出格式" default-first-option filterable>
            <el-option v-for="item in fileFormatList" :key="item" :label="item" :value="item"/>
        </el-select>    </el-form-item>
    <el-form-item label="文件分隔符" prop="writerFileDelimiter">
        <el-input v-model="form.writerFileDelimiter" placeholder="请输入文件分隔符" clearable/>
    </el-form-item>
  <el-form-item label="文件类型" prop="writerFileType">
    <el-select v-model="form.writerFileType" placeholder="请选择文件类型" default-first-option filterable>
      <el-option v-for="item in writerFileTypeList" :key="item" :label="item" :value="item"/>
    </el-select>
  </el-form-item>
  <el-form-item label="压缩模式" prop="writerZipType">
    <el-select v-model="form.writerZipType" placeholder="请输入压缩模式" default-first-option filterable>
      <el-option v-for="item in writerZipTypeList" :key="item" :label="item" :value="item"/>
    </el-select>
  </el-form-item>
  <el-form-item label="失败重试" prop="supportFailOver">
    <el-radio-group v-model="form.supportFailOverBool">
      <el-radio :label="true">是</el-radio>
      <el-radio :label="false">否</el-radio>
    </el-radio-group>
  </el-form-item>
</template>

<script setup>
import {onMounted, reactive, ref} from "vue";

const props = defineProps({
    form: {
        type: Object,
        default: () => {
        }
    },
    sourceList: {
        type: Array,
        default: () => []
    },
});
const form = reactive(props.form);
const writerFileEncodingList = ref(['UTF-8','GBK']);
const writeModeList = ref(['append','truncate','nonConflict','nonRepeat'])
const fileFormatList = ref(['csv','text']);
const writerFileTypeList = ref(['binary','txt']);
const writerZipTypeList = ref(['gzip','zip']);
onMounted(() => {
  if(form.supportFailOver != null) {
    form.supportFailOverBool = form.supportFailOver === "true";
  }
});
</script>

<style scoped>

</style>